SELECT
(
SELECT
tmp.complaintType
FROM
(
SELECT
complaintType,
COUNT(*) AS count
FROM
BOMC_CUST
WHERE
task_create_time = DATE_SUB( CURDATE(), INTERVAL 1 DAY )
GROUP BY
complaintType
ORDER BY
count DESC
LIMIT 1
) AS tmp
) AS type,
DATE_FORMAT( task_create_time, '%Y-%m-%d' ) AS date,
COUNT(*) AS count
FROM
BOMC_CUST
WHERE
task_create_time BETWEEN DATE_SUB( CURDATE(), INTERVAL 2 DAY )
AND DATE_SUB( CURDATE(), INTERVAL 1 DAY )
AND complaintType = (
SELECT
tmp2.complaintType
FROM
(
SELECT
complaintType,
COUNT(*) AS count
FROM
BOMC_CUST
WHERE
task_create_time = DATE_SUB( CURDATE(), INTERVAL 1 DAY )
GROUP BY
complaintType
ORDER BY
count DESC
LIMIT 1
) AS tmp2
)
GROUP BY
date
ORDER BY
date;